home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 459 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mail2news.demon.co.uk!intellic.demon.co.uk
  2. From: Chris Trueman <truemanc@intellic.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: char* string problem
  5. Date: Fri, 05 Jan 96 12:47:32 GMT
  6. Organization: IntelliCorp
  7. Message-ID: <820846052snz@intellic.demon.co.uk>
  8. References: <4ci7gu$68r@cloner3.netcom.com>
  9. Reply-To: truemanc@intellic.demon.co.uk
  10. X-NNTP-Posting-Host: intellic.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.30
  12. X-Mail2News-Path: intellic.demon.co.uk
  13.  
  14. In article <4ci7gu$68r@cloner3.netcom.com>
  15.            tstevens@ix.netcom.com "Edward Stevens " writes:
  16.  
  17. >        I need to prepend some switch characters to some strings passed 
  18. >to a main program which I have renamed for use as a function. 
  19. >
  20. >The calling program looks like this:
  21. >
  22. >char* the_args[4];
  23. >char* Aprefix = " -A";
  24. >char* Bprefix = " -B";
  25. >char* CPrefix = " -C";
  26. >char* Dprexix = " -D";
  27. >
  28. >the_args[0] = "user_name";
  29. >the_args[0] = strcat(Aprefix,the_args[0]);
  30.  
  31. Your problem is that the_args[0] is being set to the address of
  32. Aprefix which points to three (3) blocks of memory. By executing the
  33. strcat you are overwriting memory you have not already allocated.
  34.  
  35.             - Chris
  36.  
  37. -============================================================================-
  38. IntelliCorp Applications Consultant / E-mail: truemanc@intellic.demon.co.uk
  39. LiveModel and PowerModel are part   / CServe: 100255,701
  40. of IntelliCorp's MODELWORKS        / Tel   : +44 (0)1344 305305
  41. application development suite.      / Fax   : +44 (0)1344 305100
  42. -============================================================================-
  43.